package com.zretc.controller;

import com.util.Result;
import com.zretc.pojo.CustomerInfo;
import com.zretc.service.CustomerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Filename:    CodeMsg.java
 * Description: 客户接口 控制器
 * Copyright:   Copyright (c) 2022-2025 All Rights Reserved.
 * Company:     chinasofti.com Inc.
 * @author:     mazheng
 * @version:    1.0
 * Create at:   2022-08-19
 *
 * Modification History:
 * Date         Author      Version     Description       tag
 * ------------------------------------------------------------------
 * 2022-08-19      jiangqi      1.0         1.0 Version
 * 2022-08-19      mazheng      1.0         1.0 Version      rev
 *
 */
@RestController
@Api("用户信息模块")
@ApiOperation("CustomerController")
public class CustomerController {

    @Autowired
    private CustomerService customerService;

    /**
     * 获取所有客户信息
     * @return
     */
    @ApiOperation(value = "查询客户信息")
    @GetMapping("/findCustomer")
    public Result<List<CustomerInfo>> findCustomer() {
        // 查询客户的状态信息
        List<CustomerInfo> CustomerInfo = customerService.getCustomerInfo();
        // 返回值
        return Result.success(CustomerInfo);
    }

    /**
     * 获取所有客户信息
     * @param customerInfo  客户信息查询条件
     *                      客户名或身份id
     * @return
     */
    @GetMapping("/findCustomerByNameOrId")
    public Result<List<CustomerInfo>> getInfoByNameOrId(CustomerInfo customerInfo) {
        // 根据身份证和名字查询客户的状态信息
        List<CustomerInfo> CustomerInfo = customerService.getInfoByNameOrId(customerInfo);
        // 返回值
        return Result.success(CustomerInfo);
    }

    /**
     * 获取所有客户信息
     *
     * @param idCard  身份id
     * @return
     */
    @GetMapping("/findCustomerByIdCard")
    public Result<CustomerInfo> findCustomerByIdCard(String idCard) {
        // 根据身份证询客户的状态信息
     CustomerInfo CustomerInfo = customerService.findCustomerByIdCard(idCard);
        // 返回值
        return Result.success(CustomerInfo);
    }
}
